<?php
namespace app\Logic\Layui\Service;

use app\Logic\Logic;
use app\Tool\Str;
use app\Logic\Layui\ServiceProviders\ServiceProviderInterface;

class Register extends Logic implements ServiceInterface
{
    public $app;

    public function __construct(ServiceProviderInterface $app)
    {
        $this->app = $app;
    }


    /**
     * @return string
     * @throws \Exception
     */
    public function salt() : string
    {
        return substr(md5(Str::random(20)),0,32);
    }


    /**
     * @param string $password
     * @param string $salt
     * @return string
     */
    public function encryptPassword(string $password, string $salt) : string
    {
        $encryptPassword = md5(md5($password) . $salt);

        return substr($encryptPassword, 0, 32);
    }
}